﻿#region

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

#endregion

namespace Pob.GameObjects
{
    public class GameObject : DrawableGameComponent
    {
        #region Constructors and Destructors

        protected GameObject(Game game, string assetName, Vector2 position, float sizeFactor, Color color)
            : base(game)
        {
            AssetName = assetName;
            Position = position;
            SizeFactor = sizeFactor;
            Color = color;
        }

        #endregion

        #region Public Properties

        public Rectangle HitBox { get; protected set; }

        public Vector2 Position { get; protected set; }

        public Texture2D Textur { get; protected set; }

        #endregion

        #region Properties

        protected string AssetName { get; private set; }

        protected Color Color { get; set; }

        protected float SizeFactor { get; private set; }

        protected SpriteBatch SpriteBatch { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        ///     Zeichnet das GameObject
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch.Begin();

            SpriteBatch.Draw(Textur, Position, Color);

            SpriteBatch.End();
        }

        #endregion

        #region Methods

        /// <summary>
        ///     Lädt das GameObject
        /// </summary>
        protected override void LoadContent()
        {
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            Textur = Game.Content.Load<Texture2D>(AssetName);
            HitBox = new Rectangle((int)Position.X, (int)Position.Y, Textur.Width, Textur.Height);
        }

        #endregion
    }
}